<template>
  <div>
    <ul>
      <!-- 会根据key对比新旧dom -->
      <li v-for="item in arr" :key="item.id">{{item.name}}
        <input type="text"/>
      </li>
    </ul>
    <button @click="inNewBtn">插入新来的</button>
  </div>
</template>

<script>
export default {
  name: 'CodeApp',

  data() {
    return {
      arr:[{id:1,name:'甘甘'},{id:2,name:'绿绿'},{id:3,name:'象棋'},{id:4,name:'婷婷'},{id:5,name:'马保国'}]
    };
  },

  mounted() {
    
  },

  methods: {
    inNewBtn(){
      // splice(索引值,截取几个,修改值)
      this.arr.splice(3,0,{id:9,name:'再见'})
    }
  },
};
</script>

<style lang="scss" scoped>

</style>